/**
 * Created by vincent on 2017/9/27.
 */
moduleQuiz.controller('AddQuiz', function ($$CambioConfig, $scope, $log, LoadingService, DialogService, GaugeResource, EnumService) {
    initPage($scope);
    $scope.$on("ngDialog.opened", function () {
        dialogOnLoad();
    });

    $scope.newQuiz = {
        className: "NA",
        instruction: "NA",
        view: false,
        active: true,
        multipleEstimate: false,
        multipleTopic: false,
        guide: "NA",
        reportRemark: "NA",
        shareRouteState: "NA",
        resultRouteState: "NA",
        topicMode: Enums.GaugeTemplateTopicModeEnum.GENERAL,
        remarkStatus: "NA"
    };

    $scope.cancel = function () {
        DialogService.close();
    };

    $scope.submit = function () {
        if ($scope.addGForm.$valid) {
            //LoadingService.show();
            GaugeResource.add($scope.newGauge, function (gaugeResult) {
                $log.debug("量表新增结果", gaugeResult);
                DialogService.close();
                Alert.success();
                //LoadingService.hide();
            }, function () {
                //LoadingService.hide();
            });
        }
    };

});